package Chapter8;

//175页程序8.10

import java.awt.*;
import javax.swing.*;

public class BoxLayoutDemo {
    private JFrame frame;
    private JPanel pv, ph;

    public static void main(String[] args) {
        BoxLayoutDemo that = new BoxLayoutDemo();
        that.go();
    }

    void go() {
        frame = new JFrame("BoxLayout测试程序");
        Container contentPane = frame.getContentPane();
        pv = new JPanel();
        pv.setLayout(new BoxLayout(pv, BoxLayout.Y_AXIS));
        pv.add(new JLabel("第一个"));
        pv.add(new JLabel("第二个"));
        pv.add(new JLabel("第三个"));
        contentPane.add(pv, BorderLayout.CENTER);
        ph = new JPanel();
        ph.setLayout(new BoxLayout(ph, BoxLayout.X_AXIS));
        ph.add(new JButton("Yes"));
        ph.add(new JButton("No"));
        ph.add(new JButton("Cancel"));
        contentPane.add(ph, BorderLayout.SOUTH);
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
}
